<script>
$(function(){
	$('#start_date').val(INPUT_POST.start_date);
	$('#end_date').val(INPUT_POST.end_date);
	
	// autocomplete
	$('#searchCustomer').autocomplete('?app=daily&mod=post&opt=GetCustomer',{
		multiple:false,
		width:150,
		multipleSepartator:'',
		dataType:'json',
		minChars:0,
		parse: function(data) {
			var rows = [];
			for (var i=0; i<data.length ;i++ )
			{
				rows[rows.length] = {
					data: data[i].customer_name,
					value: data[i].customer_name,
					result:data[i].customer_name
				};
			}
			return rows;
		},
		formatItem: function(row,i,n) {
			return row;
		},
		formatResult: function(row,i,n) {
			return row;
		},
		formatMatch: function(row,i,max) {
			return row;
		}
	});
	
	
	// autocomplete
	$('#searchUser').autocomplete('?app=daily&mod=post&opt=GetUser',{
		multiple:false,
		width:150,
		multipleSepartator:'',
		dataType:'json',
		minChars:0,
		parse: function(data) {
			var rows = [];
			for (var i=0; i<data.length ;i++ )
			{
				rows[rows.length] = {
					data: data[i].username,
					value: data[i].username,
					result:data[i].username
				};
			}
			return rows;
		},
		formatItem: function(row,i,n) {
			return row;
		},
		formatResult: function(row,i,n) {
			return row;
		},
		formatMatch: function(row,i,max) {
			return row;
		}
	});
});
</script>
<form id='search' action="?">
<div class="search">
 		 <span>时间：<input rel="rili" class="input_6" value="<?=$_GET['start_date'];?>"  onclick="new Calendar(2011,2018).show(this)" type="text" readonly="readonly" name="start_date" /></span>
         <span>至：<input rel="rili" class="input_6" value="<?=$_GET['end_date'];?>" onclick="new Calendar(2011,2018).show(this)" type="text" readonly="readonly" name="end_date" /></span>
        
        <span>客户：<input class="input_5"  type="text" name="searchCustomer" id="searchCustomer" rel="searchCustomer"  value="<?=$this->customer?>" /></span>
        <span>操作员：<input type="text" name="searchUser" id="searchUser" rel="searchUser"  value="<?=$this->sel_UName?>" class="input_5" /></span>
        <span>订单状态：
        	<select id="status" name="status">
            	<option value="0" <?=$_REQUEST['status']=='0'?'selected':''; ?>>全部</option>
            	<option value="1" <?=$_REQUEST['status']=='1'?'selected':''; ?>>待分配</option>
                <option value="2" <?=$_REQUEST['status']=='2'?'selected':''; ?>>待确认</option>
                <option value="3" <?=$_REQUEST['status']=='3'?'selected':''; ?>>待出库</option>
                <option value="4" <?=$_REQUEST['status']=='4'?'selected':''; ?>>正在采购</option>
                <option value="5" <?=$_REQUEST['status']=='5'?'selected':''; ?>>已出库</option>
                <option value="6" <?=$_REQUEST['status']=='6'?'selected':''; ?>>已完结</option>
                <option value="100" <?=$_REQUEST['status']=='100'?'selected':''; ?>>已作废</option>
            </select>
        </span>
        <span>产品：<input class="input_5"  type="text" name="product" id="product" rel="product"  value="<?=$_GET['product'];?>" />
        </span>
        <span>订单号：<input class="input_5"  type="text" name="orderno" id="orderno" rel="orderno"  value="<?=$_GET['orderno'];?>" /></span>
        <span>
        	<input name="btn" type="submit" value="搜索" class="btn1"/>
            <?php echo showhide(array('app'=>$_GET['app'],'mod'=>$_GET['mod'])); ?>
            
            <input name="btn" type="submit" value="导出" class="btn1"/>
        </span>
</div>
</form>
<div class="line_1"></div>
<form id='content' action="?">
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="table1">
       <tr>
            <th class="th0">客户</th>
            <th class="th1">订单总数量</th>
            <th class="th1">订单总额度(成本)</th>
            <th class="th1">订单总额度(实际)</th>
            <th class="th1">已付款</th>
            <th class="th1">欠款</th>
            <th class="th1">订单信息</th>
       </tr>
      	 <?php foreach((array)$this->summarylist as $summary): ?>
         <tr>
       		<td><?=$summary['customer_name'];?></td>
            <td><?=$summary['countorder']; ?></td>
            <td><?=$summary['total_price'];?></td>
            <td><?=$summary['total_pprice'];?></td>
            <td><?=$summary['pays'];?></td>
            <td><?=$summary['qians'];?></td>
            <td>
            	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="table1">
                   <tr>
                        <th class="th0">订单号</th>
                        <th class="th1">下单时间</th>
                        <th class="th1">订单状态</th>
                        <th class="th1">总额度(成本)</th>
                        <th class="th1">总额度(实际)</th>
                        <th class="th1">已付款</th>
                        <th class="th1">欠款</th>
                   </tr>
                   <?php foreach((array)$this->orderlist as $order): ?>
                    	<?php if($summary['customer_id']==$order['customer_id']): ?>
                    <tr>
                        <td><?=$order['order_sn'];?></td>
                        <td><?=$order['created_time'] ? date('Y-m-d H:i',$order['created_time']) : '-'; ?></td>
                        <td><?=$order['audit_state'];?></td>
                        <td><?=$order['totoal_price'];?></td>
                        <td><?=$order['total_ppirce'];?></td>
                        <td><?=$order['payed'];?></td>
                        <td><?=$order['qian'];?></td>
                    </tr>
                    	<?php endif ?>
                   <?php endforeach; ?>
                </table>
            </td>
         </tr>
       <?php endforeach; ?>
	</table>
</form>
<div class="page_num">
     <div class="fl">
        <span></span>
     </div>
     <div class="fr">
        <p class="cpager">
            <?php echo $this->pager; ?>
        </p>
     </div>
</div>	